package com.lvhx.ehcache;

import com.lvhx.dao.OrderMapper;
import com.lvhx.dao.UserMapper;
import com.lvhx.pojo.User;
import com.lvhx.pojo.UserExample;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public class CacheRepository {

    @Autowired
    private UserMapper userMapper;

    @Cacheable(value = "selectByPrimaryKey")
    public String selectByPrimaryKey(String id){
        User order = userMapper.selectByPrimaryKey(id);
        return order.toString();
    }

    @Cacheable(value = "selectAllUser")
    public String selectAllUser(){
        UserExample example = new UserExample();
        List<User> list = userMapper.selectByExample(example);
        return list.toString();
    }

}
